<template>
<div class="table-layout">
    <div class="table-thead">
        <table class="table-info">
            <thead>
                <tr>
                    <slot name="th"></slot>
                </tr>
            </thead>
        </table>
    </div>
    <div class="table-tbody">
        <table class="table-info">
            <tbody>
                <tr v-for="(item, index) in list" :key="item.vid">
                    <slot name="td" :td="item" :index='index+1'></slot>
                </tr>
            </tbody>
        </table>
    </div>
</div>
</template>

<script>
export default {
    name: "myTable",
    props: {
        list: {
            required: true,
            type: Array
        }
    },
    computed: {
        newList() {
            return this.list
        }
    },
}
</script>

<style scoped>
.table-layout {
    width: 100%;
    height: 100%;
}
.table-thead {
    width: 100%;
}
.table-tbody {
    overflow-y: scroll;
    height: calc(100% - 46px);
}
.table-tbody::-webkit-scrollbar {
    display: none;
}
.table-info {
    table-layout: fixed;
    width: 100%;
    text-align: center;
    border-collapse: collapse;
    white-space: nowrap;
}
.table-thead tr,
.table-tbody tr:nth-of-type(2n){
    background-color: #eee;
}
.table-info th,
.table-info td {
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    height: 32px;
    line-height: 32px;
    padding: 6px 12px;
    border: 1px solid #cecece;
    box-sizing: border-box;
}
</style>